package edu.ccut.saturn.studio.logic.model.saturn;

import org.w3c.dom.Node;

import edu.ccut.saturn.studio.core.util.xml.SaturnW3CUtil;

public class SaturnMappingRule {
	private String key = "";
	private String value = "";
	private String source = "";
	private String fullkey = "";
	
	public SaturnMappingRule(SaturnMappingRule rlue){
		this.key = rlue.getKey();
		this.value = rlue.getValue();
		this.source = rlue.getSource();
		this.fullkey = rlue.getFullkey();
	}

	public String getFullkey() {
		return fullkey;
	}

	public void setFullkey(String fullkey) {
		this.fullkey = fullkey;
	}

	public SaturnMappingRule() {
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public void createNode(Node node) {
		Node ruleNode = SaturnW3CUtil.createChildNode(node, "rule", null);
		
		SaturnW3CUtil.createAttribute(ruleNode, "key", this.getKey());
		SaturnW3CUtil.createAttribute(ruleNode, "value", this
				.getValue());
		SaturnW3CUtil.createAttribute(ruleNode, "source", this
				.getSource());
		SaturnW3CUtil.createAttribute(ruleNode, "fullkey", this
				.getFullkey());
	}

	public boolean equals(Object saturnmappingrule) {
		if (saturnmappingrule instanceof SaturnMappingRule) {
			if (this.key.equals(((SaturnMappingRule) saturnmappingrule).getKey())
					&& this.value.equals(((SaturnMappingRule) saturnmappingrule)
							.getValue())
					&& this.source.equals(((SaturnMappingRule) saturnmappingrule)
							.getSource())
					&& this.fullkey.equals(((SaturnMappingRule) saturnmappingrule)
							.getFullkey())) {

				return true;
			}
		}
		return false;
	}
}
